package cn.com.shaom.learning.sb.mq.jms.example1;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;

import javax.jms.ConnectionFactory;

/**
 * ClassName: JmsConfig
 * Description:
 * Date: 2017/12/29 10:11 【需求编号】
 *
 * @author Shaom
 * @version V1.0.0
 */
//@EnableJms
//@Configuration
public class JmsConfig {

    /**
     * 本来这个方法是在 JmsAnnotationDrivenConfiguration 中配置的，可以在这边自定义
     * @param connectionFactory
     * @param configurer
     * @return
     */
//    @Bean
    public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,
                                                    DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        // This provides all boot's default to this factory, including the message converter
        configurer.configure(factory, connectionFactory);
        // You could still override some of Boot's default if necessary.
        return factory;
    }

}
